package com.powernode.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ResponseHeader;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 返回的响应
 * 刘冠志
 * 2023/1/9
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "ResultVO对象",description = "封装接口返回给前端的数据")
public class ResultVO<T> {
    //响应给前端的状态码
    @ApiModelProperty(value = "响应状态码",dataType = "int")
    private int code = 200;

    //响应给前端的提示信息
    @ApiModelProperty("响应提示信息")
    private String msg = "";

    //响应给前端的数据
    @ApiModelProperty("响应数据")
    private Object data = null;

    public static <T> ResultVO success(T data) {
        ResultVO<T> resultVO = new ResultVO<T>();
        resultVO.setData(data);
        return resultVO;
    }

    public static <T> ResultVO success() {
        ResultVO<T> resultVO = new ResultVO<T>();
        return resultVO;
    }

    public static <T> ResultVO success(Integer code,String msg) {
        ResultVO<T> result = new ResultVO<T>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

}
